<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css">
		<style>
			.mui-content-padded{margin:5px 0 0 0;}
			.mui-row-list span{float: left; line-height:33px; width:20%;}
			.mui-row-list select{float: left; line-height:14px; font-size:14px; margin-top:2px; margin-left: 5px;}
			.mui-btn-block{margin-bottom:0; padding:6px;}
			.mui-col-sm-12{ border-top: 1px solid #D1D1D1; width:100%; padding-top:5px; font-size:14px;}
			input{text-align: left;}
			input[type="text"]{height:30px; margin-bottom: 5px;}
			input[type="text"],input[type="number"]{height:26px; padding: 0;border-width:0; border-bottom: #dddddd 1px solid; margin-bottom:0;background:none;}
			input[readonly="readonly"]{ text-align: left; padding-left: 5px; padding-right: 0;}
			input{border-width: 0; height: 26px; float: right; text-align: right; padding-right: 15px;}
			form:before{ background: none !important; border: none !important;}
			
			.mui-switch:before {content: '无'; color: #fff;}
			.mui-switch{border-color: #fd933b;background-color: #fd933b;border-width: 1px;}
			.mui-switch.mui-active:before {content: '有'; color: #fff;}
			.mui-switch.mui-active {border-color: #007AFF;background-color: #007AFF;}
			
			.mui-switch.new1:before {content: '无'; color: #fff;}
			.mui-switch.new1{border-color: #fd933b;background-color: #fd933b;border-width: 1px;}
			.mui-switch.mui-active.new1:before {content: '有'; color: #fff;}
			.mui-switch.mui-active.new1 {border-color: #007AFF;background-color: #007AFF;}
			
			.mui-switch.new2:before {content: '未见异常'; color: #fff;}
			.mui-switch.new2{border-color: #fd933b;background-color: #fd933b;border-width: 1px; width:95px;}
			.mui-switch.mui-active.new2:before {content: '异常'; color: #fff;}
			.mui-switch.mui-active.new2 {border-color: #007AFF;background-color: #007AFF;}
			
			.mui-table-view-cell.mui-active{ display:block;}
			.border0{border-width: 0; border-bottom: #dddddd 1px solid;}
			.ui-alert{font-size: 14px;}
			#Popup {
				width: 0px;
				height: 0px;
				background: red;
				position: fixed;
				top: 70%;
				left: 50%;
			}
			.mui-popover{
				width: 300px;
			}
			.mui-popover .mui-popover-arrow:after {
				width: 0px;
			}
			/**/

			/**/
			.popover-cont ul{
				margin-top: 5px; 
				margin: 0; 
				padding: 0; 
				list-style: none; 
				background: #ffffff;
			}
			.table{
				width: 100%;
			}
			.thead{
				width: 100%;
				border: 1px solid #007AFF;
			}
			.thead tr{
				 width: 100%; 
				 background-color: #007AFF;
				 height: 20px;
			}
			.thead tr th{
				color: #ffffff;
				border-right: 1px solid #ffffff;
				text-align: center;
				font-family: "microsoft yahei";
				font-size: 14px;
				line-height: 20px;
			}
			.tbody{
				width: 100%;
				border: 1px solid #007AFF;
			}
			.tbody tr{
				 width: 100%; 
				 height: 20px;
			}
			.tbody tr td{
				color: #000;
				border: 1px solid #007AFF;
				text-align: center;
				font-family: "microsoft yahei";
				font-size: 14px;
				line-height: 20px;
			}
			.div-tab{
				width: 100%; 
				height: 200px; 
				overflow-y: scroll;
			}
			.div-tab::-webkit-scrollbar {
				display: none;
			}
			.submit{
				margin:0 auto 10px auto; 
				width:200px; 
				height:35px; 
				line-height: 35px; 
				background-color:#007AFF; 
				text-align: center; 
				color: #FFFFFF; 
				border-radius: 10px;
			}
			.mui-ul-check{ width: 100%; margin: 0; padding: 0;}
			.mui-ul-check li{float: left; list-style-type:none; text-align: center; padding:5px; margin:2px; border:1px solid #D1D1D1;}
			.mui-ul-check li.on{ background-color:#007AFF; color:#FFFFFF; float: left; list-style-type:none; text-align: center; padding:5px; margin:2px;}
			.mui-table-view-cell input{ text-align:left;}
			.disable{color: #bbb;}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="high_id">产前2-5</h1>
		</header>
		<div class="mui-conten" style="margin-top:50px;">
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">项目</div>
								<input id="result0" class="ui-alert"  placeholder="请选择" style="width:50%; text-align: right;"/>
							</a>
						</li>
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">所属胎次</div>
								<input id='parity' type="number" class="ui-alert border0" onkeyup="if(value>99)value=99" style="float: right; width:50%; text-align:right; padding-right: 15px;"/>
							</a>
						</li>
					</div>
				</div>
			</ul>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="width: 40%; float: left;">
								<input id="result1" class="ui-alert" value="随访"  placeholder="请选择" style="width: 50%; line-height: 26px;float:left;"/>
								<span style="float: left; line-height: 26px;">日期:</span>
							</a>
							<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="width: 50%; float: right;">
								<input id="result2" class="ui-alert"  placeholder="请选择" style="text-align: right;"/>
							</a>
						</li>
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">孕周</div>
							<div style="float: right; font-size: 14px; width: 20px; line-height: 26px; text-align: right;">周</div>
							<input id='Weeks_2' class="ui-alert border0" type="number" onkeyup="if(value>9)value=9" style="float: right; padding: 0 10px; width:50px; text-align: center; font-size: 12px;"/>
							<div style="float: right; font-size: 14px; width:10px; line-height: 26px; text-align: center;">+</div>
							<input id='Weeks_1' class="ui-alert border0" type="number" onkeyup="if(value>99)value=99" style="float: right; padding: 0 10px; width:80px; text-align: center;"/>
						</li>
					</div>
				</div>
			</ul>
		<div class="disabled" style="margin: 0; padding: 0;">
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">主诉</div>
								<input id='main' name='address' class="ui-alert border0" placeholder="" style="float: right; width:70%; text-align:right; padding-right: 15px;"/>
							</a>
						</li>
					</div>
				</div>
			</ul>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width:90px; line-height: 26px;">体重</div>
							<div style="float: right; font-size: 14px; width: 26px; line-height: 26px; text-align:left;">kg</div>
							<input id='kg' class="ui-alert border0" type="number" onkeyup="if(value>300)value=300" style="float:right; width:80px; text-align:center;"/>
						</li>
					</div>
				</div>
			</ul>
			<div style="clear:both; font-size: 16px; line-height:25px; margin-left:15px; margin-top: 5px;">产科检查</div>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">宫底高度</div>
								<div style="float: right; font-size: 14px; width: 26px; line-height: 26px; text-align:left;">cm</div>
								<input id='cm_1' class="ui-alert border0" type="number" onkeyup="if(value>100)value=100" style="float:right; width:80px; text-align:center;"/>
							</a>
						</li>
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">腹围</div>
								<div style="float: right; font-size: 14px; width: 26px; line-height: 26px; text-align:left;">cm</div>
								<input id='cm_2' class="ui-alert border0" type="number" onkeyup="if(value>200)value=200" style="float:right; width:80px; text-align:center;"/>
							</a>
						</li>
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">胎位</div>
								<input id='position' name='address' class="ui-alert border0"  placeholder="" style="float:right; width:60%; text-align:right; padding-right: 15px;"/>
							</a>
						</li>
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}'>
								<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">胎心率</div>
								<div style="float: right; font-size: 14px; width: 50px; line-height: 26px; text-align:left;">次/分钟</div>
								<input id='minutes' class="ui-alert border0" type="number" onkeyup="if(value>200)value=200" style="float:right; width:80px; text-align:center;"/>
							</a>
						</li>
					</div>
				</div>
			</ul>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width:90px; line-height: 26px;">血压</div>
							<div style="float: right; font-size: 14px; width: 50px; line-height: 26px; text-align:left;">mmHg</div>
							<input id='dbp' class="ui-alert border0" type="number" onkeyup="if(value>300)value=300" style="float:right; width:80px; text-align:center;"/>
							<div style="float: right; line-height: 26px;">/</div>
							<input id='sbp' class="ui-alert border0" type="number" onkeyup="if(value>300)value=300" style="float:right; width:80px; text-align:center;"/>
						</li>
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width:90px; line-height: 26px;">血红蛋白</div>
							<div style="float: right; font-size: 14px; width: 26px; line-height: 26px; text-align:left;">g/L</div>
							<input id='gl' class="ui-alert border0" type="number" onkeyup="if(value>300)value=300" style="float:right; width:60px; text-align:right; padding-right: 15px;"/>
						</li>
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width:90px; line-height: 26px;">尿蛋白</div>
							<input id='u_protein' type="number" onkeyup="if(value>99999)value=99999" class="ui-alert border0"  placeholder="" style="float:right; width:60%; text-align:right; padding-right: 15px;"/>
						</li>
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 14px; width:120px; line-height: 26px;">其他辅助检查*</div>
							<input id='examination' class="ui-alert border0"  placeholder="" style="float:right; width:60%; text-align:right; padding-right: 15px;"/>
						</li>
					</div>
				</div>
			</ul>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size:16px;">分类</div>
							<div class="mui-switch new1" id="mySwitch4">
							  <div class="mui-switch-handle"></div>
							</div>
						</li>
						<li class="mui-table-view-cell" id="tigshow_doc_4" style="display: none;">
							<input id='doc_4' class="ui-alert border0" placeholder="请填写" style="width:100%; text-align: right; float: right; padding-right: 15px;"/>
						</li>
					</div>
				</div>
			</ul>
			<div style="clear:both; font-size: 16px; line-height:25px; margin-left:15px; margin-top: 5px;">指导</div>
			<ul class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-col-sm-12 mui-col-xs-12">
					<li class="mui-table-view-cell">
						<ul class="mui-ul-check" id="ularry">
							<li value="605">生活方式</li>
							<li value="542">营养</li>
							<li value="541">心理</li>
							<li value="545">运动</li>
							<li value="482" text ="指导其他">其他</li>
						</ul>
					</li>
					<li class="mui-table-view-cell" id="zd_id" style="display: none;">
						<input class="ui-alert border0" id="zd" placeholder="请输入" style="float: left; width:100%; text-align: right; padding: 0 10px;"/>
					</li>
				</div>
			</ul>
			<ul  class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-col-sm-12 mui-col-xs-12">
					<li class="mui-table-view-cell">
							<div style="float: left; font-size:16px;">转诊</div>
							<div class="mui-switch new1" id="mySwitch5">
							  <div class="mui-switch-handle"></div>
							</div>
					</li>
					<li class="mui-table-view-cell" id="tigshow_doc_5" style="display: none;">
						<div style="float: left; width:100%;">
							<div style="float: left; font-size: 16px; width:50px; text-align:left;">原因:</div>
							<input id='zz_why' class="ui-alert border0"  placeholder="请输入" style="width:60%; margin-left: 6px;"/>
						</div>
						<div style="float: left; width:100%;">
							<div style="float: left; font-size: 16px; width:90px; text-align:left;">机构及科室:</div>
							<input id='zz_det' class="ui-alert border0"  placeholder="请输入" style="width:60%; margin-left: 6px;"/>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div style="float: left; font-size: 14px; width: 40px; line-height: 26px;">备注</div>
						<input class="ui-alert border0" id="note"  placeholder="请输入" style="float: right; width:70%; text-align: right; padding: 0 10px;"/>
					</li>
				</div>
			</ul>
		</div>
			<ul  class="mui-table-view" style="margin-top: 5px;">
				<div class="mui-col-sm-12 mui-col-xs-12">
					<li class="mui-table-view-cell">
						<a data-options='{"type":"date"}' class="btn mui-navigate-right">
							<div style="float: left; font-size: 14px; width: 90px; line-height: 26px;">下次随访日期</div>
							<input id="result3" class="ui-alert"  placeholder="请选择" style="width:50%; text-align: right;"/>
						</a>
					</li>
				</div>
			</ul>
			<ul class="mui-table-view disabled" style="margin-top: 5px;">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size:16px;">医生签名</div>
							<div class="mui-switch" id="mySwitch3">
							  <div class="mui-switch-handle"></div>
							</div>
						</li>
						<li class="mui-table-view-cell" id="tigshow_doc_1">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<input id='result4' class="ui-alert"  placeholder="请选择" style="width:50%; text-align: right; float: right; padding-right: 15px;"/>
							</a>
						</li>
						<li class="mui-table-view-cell" style="display: none;" id="tigshow_doc_2">
							<div style="float: left; width:100%;">
								<div style="float: left; font-size: 16px; width:5rem; text-align:center;">医院</div>
								<input id='text-doc' class="ui-alert border0"  placeholder="请输入" style="width:60%; margin-left: 6px;"/>
							</div>
							<div style="float: left; width:100%;">
								<div style="float: left; font-size: 16px; width:5rem; text-align:center;">医生</div>
								<input id='text-hosp' class="ui-alert border0"  placeholder="请输入" style="width:60%; margin-left: 6px;"/>
							</div>
						</li>
					</div>
				</div>
			</ul>
			<ul class="disabled" style="padding:10px 15px; margin: 0;">
				<p style="color: red; margin: 0;">
					提示：
					</br>
					若随方医生是省外的，则使用“填写”方式，手工输入随方医生信息。
					</br>
					若随方医生是省内的，则使用“选择”方式，选择对应医院和随方医生。
				</p>
			</ul>
			<div onclick="submit()" class="submit" >提交</div>
		</div>
		<script src="../../js/mui.js"></script>
		<script src="../../js/mui.picker.min.js"></script>
		<script src="../../js/jquery.min-1.11.1.js"></script>
		<script src="../../js/request.js"></script>
		<script type="text/javascript">
			var resultall = {"r1":[{value:'1',text:'第二次'},{value:'2',text:'第三次'},{value:'3',text:'第四次'},{value:'4',text:'第五次'}],
			 				"r2":[{value:'0',text:'随访'},{value:'1',text:'督促'}]}
			var id = 0,
				ehrId = "",
				parity = "",//胎次
				visitLevel = 2,//1、产前第一次随访 2、产前2-5次随访 3、产后随访 4、产后24天随访
				visitDate = "",//随访时间
				nextDate = "",
				doctorName = "",
				visitItem = 0,
				gestationalWeeks = 0,
				createUser = "",
				updateUser = "",
				createDate = "",
				updateDate = "",
				enableFlag = 1,
				doctorId = "",
				doctorHospId = "",
				doctorHospName = "",
				xkSign = null,
				ipOutDate = "",
				childbirthDate = "",
				versionNum = 2018,
				ifVisit = 0,
				readcardCheck = 2;
			var listdata = "";
			var selfdata = "";
			var dateov;
			var newdate = new Date();
			var self1 = localStorage.getItem("name")
			var dataself = JSON.parse(self1)
			console.log(dataself)
			doctorName = dataself.obj.userName;//责任(评估)医生名字
			doctorId = dataself.obj.id;//责任(评估)医生id
			doctorHospId = dataself.obj.hospId;//责任(评估)医生医院id
			createHospId = dataself.obj.hospId;//创建医院id
			doctorHospName = dataself.obj.hospName;//责任(评估)医生医院名称
			document.getElementById("result4").value = dataself.obj.userName;//前台显示
			mui.plusReady(function(){
				var self = plus.webview.currentWebview()
					listdata = self.data
					selfdata = JSON.parse(listdata)
					console.log(JSON.stringify(selfdata))
					//赋值
				var date1 = new Date();
				var year1=date1.getFullYear(); 
				var month1=date1.getMonth()+1;
				var day1=date1.getDate();
				var h1=date1.getHours();
				var m1=date1.getMinutes();
				var s1=date1.getSeconds();
					month1 =(month1<10 ? "0"+month1:month1); 
					day1 =(day1<10 ? "0"+day1:day1); 
					h1 =(h1<10 ? "0"+h1:h1); 
					m1 =(m1<10 ? "0"+m1:m1); 
					s1 =(s1<10 ? "0"+s1:s1);
				var newDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString())
					ehrId = selfdata.ehrId
					if(selfdata.id != undefined){
						$("#result0").attr("disabled","disabled");
						$("#result0").parent().css("pointer-events","none");
						$("#parity").attr("disabled","disabled");
						$("#parity").css("color","#ddd");
						$("#Weeks_1").attr("disabled","disabled");
						$("#Weeks_1").css("color","#ddd");
						id = selfdata.id;
						var rowsresult1=resultall.r1;
						for (var i=0; i<rowsresult1.length; i++) {
							if(selfdata.visitItem == rowsresult1[i].value){
								document.getElementById("result0").value = rowsresult1[i].text;
							}
						}
						var rowsresult2=resultall.r2;
						for (var i=0; i<rowsresult2.length; i++) {
							if(selfdata.ifVisit == rowsresult2[i].value){
								document.getElementById("result1").value = rowsresult2[i].text;
							}
						}
						if(selfdata.ifVisit == 1){
							put()
						}
						if(selfdata.visitDate != ""){//随访日期
							var datev = new Date(selfdata.visitDate);
							var yearv=datev.getFullYear(); 
							var monthv=datev.getMonth()+1;
							var dayv=datev.getDate();
								monthv =(monthv<10 ? "0"+monthv:monthv); 
								dayv =(dayv<10 ? "0"+dayv:dayv); 
							var datab = (yearv.toString()+'-'+monthv.toString()+'-'+dayv.toString());
							document.getElementById("result2").value = datab;
						}else{
							document.getElementById("result2").value = "";
						}
						document.getElementById("parity").value = selfdata.parity;
						document.getElementById("Weeks_1").value = selfdata.gestationalWeeks;
						if(selfdata.nextDate != "" && selfdata.nextDate != null ){//下次随访日期
							var datev = new Date(selfdata.nextDate);
							var yearv=datev.getFullYear(); 
							var monthv=datev.getMonth()+1;
							var dayv=datev.getDate();
								monthv =(monthv<10 ? "0"+monthv:monthv); 
								dayv =(dayv<10 ? "0"+dayv:dayv); 
							var datab = (yearv.toString()+'-'+monthv.toString()+'-'+dayv.toString());
							document.getElementById("result3").value = datab;
						}else{
							document.getElementById("result3").value = "";
						}
						doctorName = selfdata.doctorName;
						visitItem = selfdata.visitItem;
						createUser = selfdata.createUser;
						updateUser = selfdata.updateUser;
						createDate = selfdata.createDate;
						updateDate = selfdata.updateDate;
						doctorId = selfdata.doctorId;
						doctorHospId = selfdata.doctorHospId;
						doctorHospName = selfdata.doctorHospName;
						console.log(id)
						mui.ajax(getRequestUrl.url+'/mobile/ehr/maternalHealthAnswer/getVisitDetail',{
							data:{
								"m_id":id,
								"ehr_id":ehrId
							},
							dataType:'json',//服务器返回json格式数据
							type:'post',//HTTP请求类型
							timeout:10000,//超时时间设置为10秒；
							success:function(data){
								console.log("获取成功")
								var rows = data.rows;
								if (data.status == 1) {
									for(var i=0; i<rows.length; i++){
										if(rows[i].questionId == "639"){//主诉
											document.getElementById("main").value = rows[i].answer;
										}
										if(rows[i].questionId == "707"){//孕周+
											document.getElementById("Weeks_2").value = rows[i].answer;
										}
										if(rows[i].questionId == "89"){//体重
											document.getElementById("kg").value = rows[i].answer;
										}
										if(rows[i].questionId == "640"){//宫底高度
											document.getElementById("cm_1").value = rows[i].answer;
										}
										if(rows[i].questionId == "641"){//腹围
											document.getElementById("cm_2").value = rows[i].answer;
										}
										if(rows[i].questionId == "642"){//胎位
											document.getElementById("position").value = rows[i].answer;
										}
										if(rows[i].questionId == "643"){//胎心率
											document.getElementById("minutes").value = rows[i].answer;
										}
										if(rows[i].questionId == "85"){//血压1
											document.getElementById("sbp").value = rows[i].answer;
										}
										if(rows[i].questionId == "86"){//血压2
											document.getElementById("dbp").value = rows[i].answer;
										}
										if(rows[i].questionId == "161"){//血红蛋白值
											document.getElementById("gl").value = rows[i].answer;
										}
										if(rows[i].questionId == "165"){//尿蛋白
											document.getElementById("u_protein").value = rows[i].answer;
										}
										if(rows[i].questionId == "644"){//其他辅助检查
											document.getElementById("examination").value = rows[i].answer;
										}
										if(rows[i].questionId == "645"){//分类
											if(rows[i].answerId != "180"){
												mySwitch4 = "181"
												document.getElementById("tigshow_doc_4").style.display = "block";
												document.getElementById("mySwitch4").classList.add('mui-active');
											}else{
												document.getElementById("tigshow_doc_4").style.display = "none";
												document.getElementById("mySwitch4").classList.remove('mui-active');
											}
										}
										if(rows[i].questionId == "586"){//分类1
											document.getElementById("doc_4").value = rows[i].answer;
										}
										if(rows[i].questionId == "638"){//指导
											var select5Ynarr = rows[i].answer;
											if(select5Ynarr != null){
												var select5Ynarr_n = select5Ynarr.split(",");
												if(select5Ynarr_n.length != 0){
													$ ("#ularry").each (function (){
														$ (this).find ('li').each (function (){
															var y = select5Ynarr_n.length-1;
															for (var i=0; i<select5Ynarr_n.length; i++) {
																if ($(this).val() == select5Ynarr_n[i]) {
											                        $(this).addClass("on");
																	if(select5Ynarr_n[y] == "482"){
																		document.getElementById("zd_id").style.display="block";
																	}else{
																		document.getElementById("zd_id").style.display="none";
																	}
											                    }		
															}
														})
													})	
												}
											}
										}
										if(rows[i].questionId == "587"){//指导其它
											document.getElementById("zd").value = rows[i].answer;
										}
										if(rows[i].questionId == "332"){//转诊
											if(rows[i].answerId != "56"){
												mySwitch5 = "55"
												document.getElementById("tigshow_doc_5").style.display = "block";
												document.getElementById("mySwitch5").classList.add('mui-active');
											}else{
												document.getElementById("tigshow_doc_5").style.display = "none";
												document.getElementById("mySwitch5").classList.remove('mui-active');
											}
										}
										if(rows[i].questionId == "333"){//原因
											document.getElementById("zz_why").value = rows[i].answer;
										}
										if(rows[i].questionId == "334"){//科室
											document.getElementById("zz_det").value = rows[i].answer;
										}
										if(rows[i].questionId == "584"){//备注
											document.getElementById("note").value = rows[i].answer;
										}
									}
								} else {
									
								}
							},
							error:function(xhr,type,errorThrown){
								
							}
						});	
					}else{
						visitDate = newDate;//随访时间
						doctorName = dataself.obj.userName;
						createUser = dataself.obj.id;
						updateUser = dataself.obj.id;
						createDate = newDate;
						updateDate = newDate;
						doctorId = dataself.obj.id;
						doctorHospId = dataself.obj.hospId;
						doctorHospName = dataself.obj.hospName;
					};
			});	
			//内容字段部分
			mui.init()
				(function($) {
				$.init();
				var result = $('#result')[0];
				var btns = $('.btn');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						if(_self.picker) {
							_self.picker.show(function (rs) {
								result.innerText = rs.text;
								_self.picker.dispose();
								_self.picker = null;
							});
						} else {
							if(i == 0){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'第二次'},{value:'2',text:'第三次'},{value:'3',text:'第四次'},{value:'4',text:'第五次'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 if(selectItems[0].text == "第三次"){
										 addlist3()
									 }else if(selectItems[0].text == "第二次"){
										 addlist2()
									 }else if(selectItems[0].text == "第四次" || selectItems[0].text == "第五次"){
									 	 addlist4()
									 }
								  })
							}else if(i == 1){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'0',text:'随访'},{value:'1',text:'督促'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 if(selectItems[0].value == '0'){
										 ban()
									 }else if(selectItems[0].value == '1'){
										 put()
									 }
								  })
							}else{
								var optionsJson = this.getAttribute('data-options') || '{}';
								var options = JSON.parse(optionsJson);
								var id = this.getAttribute('id');
								/*
								 * 首次显示时实例化组件
								 * 示例为了简洁，将 options 放在了按钮的 dom 上
								 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
								 */
								_self.picker = new $.DtPicker(options);
								_self.picker.show(function(rs) {
									/*
									 * rs.value 拼合后的 value
									 * rs.text 拼合后的 text
									 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
									 * rs.m 月，用法同年
									 * rs.d 日，用法同年
									 * rs.h 时，用法同年
									 * rs.i 分（minutes 的第二个字母），用法同年
									 */
									$('#result'+i)[0].value = rs.text;
									/* 
									 * 返回 false 可以阻止选择框的关闭
									 * return false;
									 */
									/*
									 * 释放组件资源，释放后将将不能再操作组件
									 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
									 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
									 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
									 */
									_self.picker.dispose();
									_self.picker = null;
								});
							}
						}
					}, false);
				});
			})(mui);

			function addlist2(){
				$('#ularry li').siblings(".addtext").remove();
			}
			function addlist3(){
				addlist2();
				$('#ularry li').eq(3).after("<li value='562' class='addtext'>自我监测</li><li value='547' class='addtext'>母乳喂养</li>");
			}
			function addlist4(){
				addlist2();
				$('#ularry li').eq(3).after("<li value='562' class='addtext'>自我监测</li><li value='563' class='addtext'>分娩准备</li><li value='547' class='addtext'>母乳喂养</li>");
			}
			//禁止输入
			function ban(){
				$(".disabled").show();
			}
			function put(){
				$(".disabled").hide();
			}
			//切换
			document.getElementById("mySwitch3").addEventListener("toggle",function(event){
				if(event.detail.isActive){
					document.getElementById("tigshow_doc_1").style.display="none";
					document.getElementById("tigshow_doc_2").style.display="block";
					doctorHospId = "0";//签名医生医院id
					doctorHospName = document.getElementById("text-hosp").value;//签名医生医院名字
					doctorId = "0";//签名医生id
					doctorName = document.getElementById("text-doc").value;//签名医生姓名
				}else{
					document.getElementById("tigshow_doc_1").style.display="block";
					document.getElementById("tigshow_doc_2").style.display="none";
					if(doctorId == ""){
						doctorHospId = "";//签名医生医院id
						doctorHospName = "";//签名医生医院名字
						doctorId = "";//签名医生id
						doctorName = "";//签名医生姓名
					}
				}
			})
			//切换
			var mySwitch4 = "180";
				mySwitch5 = "56";
			document.getElementById("mySwitch4").addEventListener("toggle",function(event){
				if(event.detail.isActive){
					document.getElementById("tigshow_doc_4").style.display="block";
					mySwitch4 = "181";
				}else{
					document.getElementById("tigshow_doc_4").style.display="none";
					mySwitch4 = "180";
					$("#doc_4").val("");
				}
			})
			document.getElementById("mySwitch5").addEventListener("toggle",function(event){
				if(event.detail.isActive){
					document.getElementById("tigshow_doc_5").style.display="block";
					mySwitch5 = "55";
				}else{
					document.getElementById("tigshow_doc_5").style.display="none";
					mySwitch5 = "56";
					$("#zz_why").val("");
					$("#zz_det").val("");
				}
			})
			//复选框事件
			mui('.mui-ul-check').on('tap', 'li', function(e) {
				var index = this.getAttribute('value');
				var text = this.getAttribute('text');
				var remove_class = this.getAttribute('class')
				if(this.getAttribute('class') != "on"){
					this.classList.add('on');
					if(text == "指导其他"){
						$("#zd_id").show();
					}
				}else{
					this.classList.remove('on');
					if(text == "指导其他" && remove_class){
						$("#zd_id").hide();
						$("#zd").val("");
					}
				}
			});
			//提交
			var select1 = "";
			function submit(){
				if($("#parity")[0].value == ""){
					alert("请输入胎次")
				}else if($("#result0")[0].value == ""){
					alert("请选择项目")
				}else if($("#result2")[0].value == ""){
					alert("请输入随访时间")
				}else if($("#examination")[0].value == ""){
					alert("请输入带*号的必填项")
				}else if($("#result4")[0].value == "" && $("#text-doc")[0].value == ""){
					alert("请输入医生签名")
				}else{
					alert("可以提交")
					parity = $("#parity")[0].value;
					gestationalWeeks = $("#Weeks_1")[0].value;
				//多选1
				select1 = "";
				$ ("#ularry").find ('.on').each (function (){
					if($(this).length != 0){
						select1 += $(this).val() + ",";	
					}
				});
				//去掉最后一个逗号(如果不需要去掉，就不用写)
				if (select1.length > 0) {
					select1 = select1.substr(0,select1.length - 1);
				}else{
					select1 = "";
				}
				var visitItem_arr = $('#result0')[0].value;
				for(var re=0; re<resultall.r1.length; re++){
					if(visitItem_arr == resultall.r1[re].text){
						visitItem = resultall.r1[re].value;//项目
					};
				};
				var ifVisit_arr = $('#result1')[0].value;
				for(var re=0; re<resultall.r2.length; re++){
					if(ifVisit_arr == resultall.r2[re].text){
						ifVisit = resultall.r2[re].value;//随访/督促
					};
				};
				if($("#result2")[0].value != ""){
					visitDate = $("#result2")[0].value+" 00:00:00";
				}else{
					visitDate = "";
				}
				if($("#result3")[0].value != ""){
					nextDate = $("#result3")[0].value+" 00:00:00";
				}else{
					nextDate = "";
				}
				$.ajax(getRequestUrl.url+"/mobile/ehr/MaternalHealth/addOrUpdate",{
					data:{
						id : id,
						ehrId : ehrId,
						parity : parity,//胎次
						visitLevel : visitLevel,//1、产前第一次随访 2、产前2-5次随访 3、产后随访 4、产后24天随访
						visitDate : visitDate,//随访时间
						nextDate : nextDate,
						doctorName : doctorName,
						visitItem : visitItem,
						gestationalWeeks : gestationalWeeks,
						createUser : createUser,
						updateUser : updateUser,
						createDate : createDate,
						updateDate : updateDate,
						enableFlag : enableFlag,
						doctorId : doctorId,
						doctorHospId : doctorHospId,
						doctorHospName : doctorHospName,
						xkSign : xkSign,
						ipOutDate : ipOutDate,
						childbirthDate : childbirthDate,
						versionNum : versionNum,
						ifVisit : ifVisit,
						readcardCheck : readcardCheck
						},
					dataType:'json',//服务器返回json格式数据
					type:'post',//HTTP请求类型
					timeout:10000,//超时时间设置为10秒；
					success:function(data){
						console.log("成功1")
						console.log(ifVisit)
						if(ifVisit != "1" && data.status == 1){
							console.log("呵呵呵呵")
							var mid = data.total;
							var data_object =[
								//孕周+
								{
								questionId:"707",
								answerId:0,
								answer:$('#Weeks_2').val()
								},
								//主诉
								{
								questionId:"639",
								answerId:0,
								answer:$('#main').val()
								},
								//体重
								{
								questionId:"89",
								answerId:0,
								answer:$('#kg').val()
								},
								//宫底高度
								{
								questionId:"640",
								answerId:0,
								answer:$('#cm_1').val()
								},
								//腹围
								{
								questionId:"641",
								answerId:0,
								answer:$('#cm_2').val()
								},
								//胎位
								{
								questionId:"642",
								answerId:0,
								answer:$('#position').val()
								},
								//胎心率
								{
								questionId:"643",
								answerId:0,
								answer:$('#minutes').val()
								},
								//血压1
								{
								questionId:"85",
								answerId:0,
								answer:$('#sbp').val()
								},
								//血压2
								{
								questionId:"86",
								answerId:0,
								answer:$('#dbp').val()
								},
								//血红蛋白
								{
								questionId:"161",
								answerId:0,
								answer:$('#gl').val()
								},
								//尿蛋白
								{
								questionId:"165",
								answerId:0,
								answer:$('#u_protein').val()
								},
								//其他辅助检查*
								{
								questionId:"644",
								answerId:0,
								answer:$('#examination').val()
								},
								//分类
								{
								questionId:"645",
								answerId:mySwitch4,
								answer:null
								},
								//分类其它
								{
								questionId:"586",
								answerId:0,
								answer:$('#doc_4').val()
								},
								//指导
								{
								questionId:"638",
								answerId:0,
								answer:select1
								},
								//指导其它
								{
								questionId:"587",
								answerId:0,
								answer:$('#zd').val()
								},
								//转诊
								{
								questionId:"332",
								answerId:mySwitch5,
								answer:null
								},
								//原因
								{
								questionId:"333",
								answerId:0,
								answer:$('#zz_why').val()
								},
								//科室
								{
								questionId:"334",
								answerId:0,
								answer:$('#zz_det').val()
								},
								//备注
								{
								questionId:"584",
								answerId:0,
								answer:$('#note').val()
								}
							]
							for(var i=0; i<data_object.length; i++){
								data_object[i].ehrId = ehrId;
								data_object[i].mid = mid;
							}
							$.ajax(getRequestUrl.url+"/mobile/ehr/maternalHealthAnswer/addOrUpdate",{
								data:JSON.stringify(data_object),
								dataType:'json',//服务器返回json格式数据
								type:'post',//HTTP请求类型
								contentType : 'application/json;charset=utf-8',
								success:function(data){
									console.log("成功")
								},
								error:function(xhr,type,errorThrown){
									
								}
							});	
						}
					},
					error:function(xhr,type,errorThrown){
						
					}
				});
				}
			}
		</script>
	</body>
</html>